<?php
use kartik\form\ActiveForm;
use yii\bootstrap\Html;
use wodrow\yii2wtools\tools\JsBlock;
use yii\helpers\Url;
use common\Tools;
use yii\web\JsExpression;
use kartik\select2\Select2;
/**
 * @var \yii\web\View $this
 * @var $model \frontend\modules\custom\models\forms\Custom
 * @var $inviteCode \common\models\db\UserRegisterInviteCode
 */
$this->title = "分账通个人用户注册";
$fztBanks = [];
foreach (Yii::$app->fenZhangTong->getBanks() as $k => $v) {
    $fztBanks[$v['code']] = "[{$v['code']}]{$v['name']}";
}
?>

<div>
    <div class="row">
        <div class="col-xs-12">
            <p class="text-warning">
                该链接于
                <span class="text-danger">
                    <?=Tools::toDate($inviteCode->created_at + $inviteCode->period - 600) ?>
                </span>
                过期
            </p>
        </div>
        <div class="col-xs-12">
            <?php $form = ActiveForm::begin(); ?>
            <?=$form->field($model, 'code')->textInput(['readonly' => true]) ?>
            <div class="row">
                <div class="col-xs-12 col-sm-7">
                    <?=$form->field($model, 'username')->textInput([]) ?>
                    <?=$form->field($model, 'password')->passwordInput([]) ?>
                    <?=$form->field($model, 'rePassword')->passwordInput([]) ?>
                </div>
                <div class="clearfix"></div>
                <div class="col-xs-6 col-sm-2">
                    <?=$form->field($model, 'cust_name')->textInput([]) ?>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <?=$form->field($model, 'id_type')->dropDownList($model->getIdTypeDesc()) ?>
                </div>
                <div class="col-xs-12 col-sm-7">
                    <?=$form->field($model, 'id_no')->textInput([]) ?>
                </div>
                <div class="clearfix"></div>
                <div class="col-xs-12 col-sm-2">
                    <?=$form->field($model, 'mobile_no')->textInput([]) ?>
                </div>
                <div class="col-xs-12 col-sm-3">
                    <?=$form->field($model, 'open_bank')->widget(Select2::class, [
                        'options' => ['placeholder' => '你可以查询后选择'],
                        'data' => $fztBanks,
//                        'pluginOptions' => [
//                            'placeholder' => '查询',
//                            'allowClear' => true,
//                            'ajax' => [
//                                'url' => Url::to(['/public/ajax-get-fzt-banks']),
//                                'dataType' => 'json',
//                                'data' => new JsExpression('function(params) { return {q:params.term}; }')
//                            ],
//                            'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
//                            'templateResult' => new JsExpression('function(res) { return res.text; }'),
//                            'templateSelection' => new JsExpression('function (res) { return res.text; }'),
//                        ],
//                        'pluginEvents' => [
//                            'change' => 'function() { noauthCourierExclusivePackagePlaceOrder.toCountyId = $(this).val(); }'
//                        ],
                    ]) ?>
                </div>
                <div class="col-xs-12 col-sm-7">
                    <?=$form->field($model, 'card_no')->textInput([]) ?>
                </div>
                <div class="clearfix"></div>
                <div class="col-xs-6 col-sm-2">
                    <?=$form->field($model, 'gender')->dropDownList($model->getGenderDesc(), ['prompt' => "请选择"]) ?>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <?=$form->field($model, 'birth_day')->textInput(['placeholder' => "YYYYMMDD"]) ?>
                </div>
                <div class="col-xs-12 col-sm-7">
                    <?=$form->field($model, 'email')->textInput([]) ?>
                </div>
                <div class="clearfix"></div>
                <div class="col-xs-6 col-sm-6">
                    <?=$form->field($model, 'legal_expire_date')->textInput([]) ?>
                </div>
                <div class="col-xs-6 col-sm-6">
                    <?=$form->field($model, 'legal_auth_date')->textInput([]) ?>
                </div>
                <div class="clearfix"></div>
                <div class="col-xs-12 col-sm-4">
                    <?=$form->field($model, 'occupation')->dropDownList($model->getOccupationDesc(), ['prompt' => "请选择"]) ?>
                </div>
                <div class="clearfix"></div>
                <div class="col-xs-12 col-sm-6">
                    <?=$form->field($model, 'address')->textarea([]) ?>
                </div>
                <div class="col-xs-12 col-sm-6">
                    <?=$form->field($model, 'legal_address')->textarea([]) ?>
                </div>
                <div class="clearfix"></div>
                <div class="col-xs-12 col-sm-8">
                    <?=$form->field($model, 'issue_office')->textInput(['placeholder' => "XXX公安局"]) ?>
                </div>
                <div class="clearfix"></div>
            </div>
            <?= Html::submitButton('注册', ['class' => 'btn btn-primary btn-block btn-flat']) ?>
            <?php ActiveForm::end(); ?>
        </div>
    </div>
</div>

<?php JsBlock::begin(); ?>
    <script>
        $(function (){});
    </script>
<?php JsBlock::end(); ?>